package com.zprmb.udzt.view;

import android.app.Activity;
import android.app.Dialog;
import android.os.Handler;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

import com.zprmb.udzt.R;

public class WebViewDialog extends Dialog {
	
	private Activity mActivity;
	//private TextView loadingText;

	public WebViewDialog(Activity context) {
		super(context, R.style.dialog_normal);
		mActivity = context;
		setContentView(R.layout.loading);//loading
		setProperty();
		setCancelable(true);
//		getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);  
		//loadingText = (TextView) findViewById(R.id.loading_text);
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		return false;
	}
	
	/*public void setLoadingMessage(String message){
		if(!TextUtils.isEmpty(message)){
			loadingText.setText(message);
		}
	}*/

	/*public void show(String message) {
		if(!TextUtils.isEmpty(message)){
			loadingText.setText(message);
		}
		super.show();
	}
*/   @Override
public void show() {
	// TODO Auto-generated method stub
	super.show();
	handler.sendEmptyMessageDelayed(1, 3000);
	
}
Handler handler=new Handler(){
	public void handleMessage(android.os.Message msg) {
		dismiss();
	};
};
	public void close() {
		if (!mActivity.isFinishing()) {
			mActivity.runOnUiThread(new Runnable() {
				public void run() {
					if (isShowing()) {
						dismiss();
					}
				}
			});
		}
	}

	private void setProperty() {
		Window window = getWindow();
		WindowManager.LayoutParams p = window.getAttributes();
		Display d = getWindow().getWindowManager().getDefaultDisplay();
		p.height = (int) (d.getHeight() * 1);
		p.width = (int) (d.getWidth() * 1);
		window.setAttributes(p);
	}
}
